package com.example.hand.dao;

import com.example.hand.bean.User;
import org.apache.ibatis.annotations.*;

import java.util.HashMap;
import java.util.List;

@Mapper
public interface UserDao {
    @Select("SELECT * FROM user WHERE user_name = #{user_name} AND user_password = #{user_password}")
    User getLogin(@Param("user_name") String user_name, @Param("user_password") String user_password);

    @Insert("insert into user(user_name, user_password, user_age,user_sex) values (#{user_name},#{user_password},#{user_age},#{user_sex})")
    int saveUserInfo(User user);

    @Select("SELECT * FROM user WHERE user_name = #{user_name}")
    List<User> findByUser(@Param("user_name")String user_name);

    @Select("select count(*) from user")//分页
    int selectCountUser();

    @Select("select * from user limit #{start},#{size}")
    List<User> userPage(HashMap<String, Integer> map);//分页sql对应的方法

    @Select("select *from user where user_name LIKE #{query_content}")
    List<User> queryUserByLike(String content);//搜索框，根据名字查询。

    @Delete("delete from user where user_id=#{user_id}")
    int deleteByPrimaryKey(int user_id);//删除

    @Select("select *from user where user_id=#{user_id}")
    User selecttest(Integer user_id);//进入修改页面，并且在input框里面拿到对应主页面的数据。

    @Update("update user set user_name=#{user_name},user_password=#{user_password},user_age=#{user_age},user_sex=#{user_sex} where user_id=#{user_id}")
    int updateByPrimaryKeySelective(User user);//修改执行

    @Select("select *from orders")
    List<User> selectByAll();//修改后查询

}
